package cn.virens.common.project.base.utils;

import cn.virens.common.util.exception.APIException;
import org.dromara.hutool.core.date.DateUtil;

import java.time.LocalDateTime;

public class DayUtil {
    public static String dateYMD() {
        return DateUtil.formatToday();
    }

    public static String dateYMDhms() {
        return DateUtil.formatNow();
    }

    public static String lastWeekYMD() throws APIException {
        return DateUtil.lastWeek().toDateStr();
    }

    public static String lastWeekYMDhms() throws APIException {
        return DateUtil.lastWeek().toStringDefaultTimeZone();
    }

    public static String nextWeekYMD() throws APIException {
        return DateUtil.nextWeek().toDateStr();
    }

    public static String nextWeekYMDhms() throws APIException {
        return DateUtil.nextWeek().toStringDefaultTimeZone();
    }

    public static String lastMonthYMD() throws APIException {
        return DateUtil.lastMonth().toDateStr();
    }

    public static String lastMonthYMDhms() throws APIException {
        return DateUtil.lastMonth().toStringDefaultTimeZone();
    }

    public static String nextMonthYMD() throws APIException {
        return DateUtil.nextMonth().toDateStr();
    }

    public static String nextMonthYMDhms() throws APIException {
        return DateUtil.nextMonth().toStringDefaultTimeZone();
    }

    public static String tomorrowYMD() throws APIException {
        return DateUtil.tomorrow().toDateStr();
    }

    public static String tomorrowYMDhms() throws APIException {
        return DateUtil.tomorrow().toStringDefaultTimeZone();
    }

    public static String yesterdayYMD() throws APIException {
        return DateUtil.yesterday().toDateStr();
    }

    public static String yesterdayYMDhms() throws APIException {
        return DateUtil.yesterday().toStringDefaultTimeZone();
    }

    public static boolean afterNow(LocalDateTime dateTime) throws APIException {
        return dateTime != null && LocalDateTime.now().isAfter(dateTime);
    }

    public static boolean beforeNow(LocalDateTime dateTime) throws APIException {
        return dateTime != null && LocalDateTime.now().isBefore(dateTime);
    }

    public static LocalDateTime plus(Integer seconds) throws APIException {
        return LocalDateTime.now().plusSeconds(seconds);
    }
}
